# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=kind
pkgver=0.14.0
pkgrel=0
pkgdesc="Kubernetes IN Docker - local clusters for testing Kubernetes"
url="https://kind.sigs.k8s.io/"
license="Apache-2.0"
arch="all"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/kubernetes-sigs/kind/archive/v$pkgver/kind-$pkgver.tar.gz"

export GOFLAGS="$GOFLAGS -trimpath -mod=readonly -modcacherw"
export GOPATH="$srcdir"
export CGO_ENABLED=0

build() {
	go build -ldflags "-s -w"

	./kind completion bash > $pkgname.bash
	./kind completion fish > $pkgname.fish
	./kind completion zsh > $pkgname.zsh
}

check() {
	# skip tests that require a running Docker daemon
	local packages="$(go list ./... | \
		grep -v "sigs.k8s.io/kind/pkg/cluster/internal/providers/docker")"
	go test $packages
}

package() {
	install -Dm755 kind -t "$pkgdir"/usr/bin

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/completions/$pkgname.fish
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
655a801cf25d807bb7ea29aecacbb4b16ae6afcd147515ad2462a2ba59156758d4039a21e8d30fbd52c1d406fe4f7ae115956c79cade68eaa403f6e9487ef75e  kind-0.14.0.tar.gz
"
